// (Estimate p) p can be computed using the following series:
// 斐波那契数列
// Write a method that returns m(i) for a given i and write a test program that displays the following table:



public class test614 {
    
    public static double m(int i) {
        double sum = 0.0;
        for (int n = 1; n <= i; n++) {
            // 计算符号：(-1)^(n+1)
            double sign = (n % 2 == 1) ? 1.0 : -1.0;
            // 计算分母：2n-1
            double denominator = 2 * n - 1;
            // 累加每一项
            sum += sign / denominator;
        }
        return 4 * sum;
    }
    
    public static void main(String[] args) {
        // 显示表格标题
        System.out.println("i\t\tm(i)");
        System.out.println("---------------------");
        
        // 定义要计算的i值
        int[] iValues = {1, 101, 201, 301, 401, 501, 601, 701, 801, 901};
        
        // 计算并显示每个i对应的m(i)值
        for (int i : iValues) {
            double result = m(i);
            // 格式化输出，保留4位小数
            System.out.printf("%d\t\t%.4f\n", i, result);
        }
    }
}